﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Pavilion.DesignerTool
{
    public class DrawingBoardData
    {
        public Vector2 PenPosition { get; set; }
        public TextureData TextureData { get; set; }
        public FrameData FrameData { get { return (AnimationSelectionInfo != null) ? AnimationSelectionInfo.CurrentFrameData : null; } }
        public Vector2 CurrentTexturePositionOnBoard { get { return AnimationSelectionInfo.CurrentAnimationLayer.PositionOnBoard; } set { AnimationSelectionInfo.CurrentAnimationLayer.PositionOnBoard = value; } }
        public float PressurePercentage { get; set; }
        public AnimationSelectionInfo AnimationSelectionInfo { get; set; }
        public float Scale { get; set; }
        public bool IsMouseInsideDrawingBoard { get; set; }

        public Vector2 GetAdjustedPenPosition()
        {
            return (PenPosition - CurrentTexturePositionOnBoard) / Scale;
        }

        public bool IsPenInsideCurrentTexture
        {
            get
            {
                Rectangle rectangle = new Rectangle((int)(CurrentTexturePositionOnBoard.X), (int)(CurrentTexturePositionOnBoard.Y), (int)(TextureData.Texture.Width * Scale), (int)(TextureData.Texture.Height * Scale));
                return PolygonBox.IsInsideRectangle(rectangle, PenPosition);
            }
        }
    }
}
